package com.zw.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.zw.annotation.Excel;
import com.zw.annotation.Excels;
import com.zw.core.domain.entity.SysUser;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 目录信息
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "directory", description = "目录信息")
@TableName("pt_directory")
public class Directory implements Serializable {

    @Excel(name = "目录编号")
    @Schema(description = "目录ID")
    private Long id;

    @Excel(name = "目录名称")
    @NotBlank(message = "目录名称不能为空")
    @Schema(description = "目录名称")
    private String name;

    @Schema(description = "父级目录ID")
    private Long parentId;

    @Schema(description = "用户ID")
    private Long userId;

    @Excels({
            @Excel(name = "创建人", targetAttr = "userName")
    })
    @TableField(exist = false)
    private SysUser user;

    @Excel(name = "创建时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private LocalDateTime createTime;

    @Excel(name = "更新时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    @Schema(description = "删除标志")
    @TableLogic(value = "0", delval = "1")
    private Integer delFlag;
}
